<?php
	$gallery_id = $params[3];
	if($_SERVER["REQUEST_METHOD"]=='POST') {
		$title			= strip_tags($_POST['title']);
		$ip				= getUserIP();

		$upload_fieldname	= 'image';
		$upload_extension	= file_ext($_FILES[$upload_fieldname]['name']);
		$upload_fullpath	= '../contents/product/'.md5('thumb'.time()).$upload_extension;
		if (move_uploaded_file($_FILES[$upload_fieldname]['tmp_name'], $upload_fullpath)) {
			$upload_sql = ", `image` = '". basename($upload_fullpath) ."'";
		}

		$sql = "UPDATE `tbl_color_gallery` SET `title` = '$title' $upload_sql  WHERE  `gallery_id` = '$gallery_id' LIMIT 1;";
		mysql_query($sql);
		redirect('../');
		exit;
	}

	$sql = "SELECT * FROM `tbl_color_gallery` WHERE `gallery_id` = '$gallery_id' LIMIT 1";
	$query = mysql_query($sql);
	while($result = mysql_fetch_assoc($query)) {
		$title		= $result['title'];
		$imageHTML	= $result['image'] ? "<img src=\"/thumb/250/zc/contents/product/{$result['image']}\" /><br />": "";
	}
	mysql_free_result($query);
?>